package com.smartrobot.smartrobot.circle;

import android.content.Context;
import android.os.Looper;
import com.smartrobot.smartrobot.Common.CommonFunc;
import com.smartrobot.smartrobot.DB.FriendListSqlHelper;
import com.smartrobot.smartrobot.pojo.getFriendListPojo;
import com.smartrobot.smartrobot.pojo.saveFriendListPojo;

import java.util.List;

/**
 * Created by Administrator on 2014/12/23.
 */
public class CircleUtil {



    public static  boolean isFriendChange = false;
    public static boolean isAllChange = false;

    public static void  saveFriendList(final saveFriendListPojo pojos,final Context context,final String userId){

        Thread t = new Thread() {

            @Override
            public void run() {
                Looper.prepare();
                FriendListSqlHelper friendListSqlHelper = new FriendListSqlHelper(context, CommonFunc.stringToMD5(userId));
                friendListSqlHelper.open();
                friendListSqlHelper.insertAllFriendList(pojos);
                friendListSqlHelper.close();
            }
        };
        t.start();
    }


    public static boolean deleteAllFriendList(final  Context context,final String userId){
        boolean suc = false;
        FriendListSqlHelper friendListSqlHelper = new FriendListSqlHelper(context,CommonFunc.stringToMD5(userId));
        friendListSqlHelper.open();
        suc = friendListSqlHelper.deleteAllFromNewFriend();
        friendListSqlHelper.close();
        return suc;
    }
    public static saveFriendListPojo getFriendList(final  Context context,final String userId){
        FriendListSqlHelper friendListSqlHelper = new FriendListSqlHelper(context,CommonFunc.stringToMD5(userId));
        friendListSqlHelper.open();
        saveFriendListPojo pojos =  friendListSqlHelper.searchAllFromFriendList();
        friendListSqlHelper.close();
        return pojos;
    }

    public static void  saveFriend(final getFriendListPojo pojos,final Context context,final String userId,final String userType){

        FriendListSqlHelper friendListSqlHelper = new FriendListSqlHelper(context, CommonFunc.stringToMD5(userId));
        friendListSqlHelper.open();
        friendListSqlHelper.insertFriendList(pojos,userType);
        friendListSqlHelper.close();
    }


}
